﻿namespace Modbus.Messages
{
	internal sealed class MaskWriteRegisterMessage : ModbusMessage
	{
		private ushort registerAddress;
		private short  andMask;
		private short  orMask;

		public override void Read(ModbusReader reader)
		{
			base.Read(reader);

			this.registerAddress = reader.ReadUInt16();
			this.andMask = reader.ReadInt16();
			this.orMask = reader.ReadInt16();
		}

		public override void Write(ModbusWriter writer)
		{
			base.Write(writer);

			writer.Write(this.registerAddress);
			writer.Write(this.andMask);
			writer.Write(this.orMask);
		}

		public ushort RegisterAddress
		{
			get { return this.registerAddress; }
			set { this.registerAddress = value; }
		}

		public short AndMask
		{
			get { return this.andMask; }
			set { this.andMask = value; }
		}

		public short OrMask
		{
			get { return this.orMask; }
			set { this.orMask = value; }
		}
	}
}
